package services

import (
	"shyxy-model-agent/core/model"
	"shyxy-model-agent/core/repository"
)

func InsertOnlineModelInfo(name, modelType, description, category, grpcExecutableFileName, grpcArguments, uri, apiKey string, modelInfoRepo repository.ModelInfoRepository, onlineModelRepo repository.OnlineModelRepository) error {
	modelInfo := model.ModelInfo{
		Name:                   name,
		Category:               category,
		Type:                   modelType,
		Description:            description,
		GrpcExecutableFileName: grpcExecutableFileName,
		GrpcArguments:          grpcArguments,
		Status:                 "sttoped",
	}
	id, err := modelInfoRepo.Create(&modelInfo)
	if err != nil {
		return err
	}
	onlineModel := model.OnlineModel{
		ModelInfoID: id,
		ModelName:   name,
		Uri:         uri,
		ApiKey:      apiKey,
	}
	return onlineModelRepo.Create(&onlineModel)
}
